﻿using DadayunApi;
using DadayunApi.Model;
using KhtApi.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace KhtApi.DAL
{
    public class KhtDAL
    {
        protected FormApi formApi;
        protected ReportApi reportApi;
        protected BaseApi baseApi;
        public string ErrMsg { get; private set; }
       
        public KhtDAL(AppAuthBase authBase, string baseUri)
        {
            formApi = new FormApi(authBase, baseUri);
            reportApi = new ReportApi(authBase, baseUri);
            baseApi = new BaseApi(authBase, baseUri);

        }

      

        /// <summary>
        /// 调试用，用来返回系统响应的JSON字串
        /// </summary>
        public string ResponseJson
        {
            get
            {
                return formApi.ResponseJson;
            }
        }
        public bool DdyReady()
        {
            
            AccessToken token= baseApi.GetToken();
            ErrMsg = baseApi.ResponseJson;
            return token != null;
        }

        internal FormTlpInfo GetFormTemplate(string formName)
        {
            return formApi.GetFormTemplate(formName);
        }
       
       


        public ReportTplDetail GetReportTemplate(string reportIdOrName)
        {
            return reportApi.GetReportTemplateDetails(reportIdOrName);
        }
    }
}
